import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

//封装FlutterToast,默认提示在屏幕中间,并且对msg默认初始化为空字符串,防止app因为msg为空而崩溃
void flutterToast(
{
  String? msg,
  Toast? toastLength,
  int timeInSecForIosWeb = 1,
  double? fontSize,
  ToastGravity gravity = ToastGravity.CENTER,
  Color? backgroundColor,
  Color? textColor,
  bool webShowClose = false,
  webBgColor: "linear-gradient(to right, #00b09b, #96c93d)",
  webPosition: "right",
}
    ) {
  if (msg == null || msg == '') {
    return;
  }
  Fluttertoast.showToast(msg: msg ,
    toastLength: toastLength,
    timeInSecForIosWeb: timeInSecForIosWeb,
    fontSize: fontSize,
    gravity: gravity,
    backgroundColor: backgroundColor,
    textColor: textColor,webShowClose: false,
    webBgColor: webBgColor,
    webPosition: webPosition
  );
}